#version 450 core

layout (location = 0) out vec4 o_Color;
//out int o_EntityID;

struct VertexOutput
{
	vec4 Color;
	vec2 TexCoord;
	float TilingFactor;
};

layout (location = 0) in VertexOutput Output;
layout (location = 3) in float v_TexIndex;
layout (location = 4) in flat int v_EntityID;

uniform sampler2D u_Textures[5];

void main()
{
	vec4 texColor = Output.Color;

	switch(int(v_TexIndex))
	{
		case  0: texColor *= texture(u_Textures[0], Output.TexCoord * Output.TilingFactor); break;
		case  1: texColor *= texture(u_Textures[1], Output.TexCoord * Output.TilingFactor); break;
		case  2: texColor *= texture(u_Textures[2], Output.TexCoord * Output.TilingFactor); break;
		case  3: texColor *= texture(u_Textures[3], Output.TexCoord * Output.TilingFactor); break;
		case  4: texColor *= texture(u_Textures[4], Output.TexCoord * Output.TilingFactor); break;
	}
	if (texColor.a == 0.0)
		discard;

	o_Color = texColor;
	//o_EntityID = v_EntityID;
}
